package com.hrp.hrpdao;

import com.hrp.domain.Menus;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by Administrator on 2018/8/3 0003.
 */
@Mapper
public interface MenusDao {

    //@Select("select * from Menus where parentId=#{parentId}")
    //public List<Menus> getMenus(@Param("parentId") Integer parentId);

    @Select("select a.* from Menus  a left join HRP_Role_Menu b on a.id=b.menuId left join HRP_User_Role c on b.roleId=c.roleId left join HRP_User d on c.userId=d.id where d.username=#{username} and a.parentId=#{parentId}")
    public List<Menus> getMenus(@Param("username") String username,@Param("parentId") Integer parentId);

    @Select("select a.id,a.parentId,a.text,iconCls,state,a.menuUrl,a.sortId from Menus a inner join HRP_Role_Menu b on a.id=b.menuId where roleId=#{roleId}")
    List<Menus> findMenusListByRoleId(@Param("roleId")Integer roleId);

}
